<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
      <template #operationBeforeExtend="{ record }">
        <a-link @click="handleMingxi(record)">明细</a-link>
      </template>
    </ma-crud>
    <a-drawer
        :footer="false"
        :width="1400"
        v-model:visible="mingxiShow"
        >
        <template #title> 明细 </template>
        <goodsPriceDetail  v-if="mingxiShow" :info="itemData" />
      </a-drawer>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import financialGoodsPrice from '@/api/financial/financialGoodsPrice'
import goodsPriceDetail from '@/views/financial/goodsPriceDetail/index.vue'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()
const itemData = ref({})
const mingxiShow = ref(false)
const handleMingxi = (row)=>{
  itemData.value =  row
  mingxiShow.value = true
}

const options = reactive({
  id: 'flyos_financial_goods_price',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationWidth: 160,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  api: financialGoodsPrice.getList,
  recycleApi: financialGoodsPrice.getRecycleList,
  add: {
    show: true,
    api: financialGoodsPrice.save,
    auth: ['financial:goodsPrice:save']
  },
  edit: {
    show: true,
    api: financialGoodsPrice.update,
    auth: ['financial:goodsPrice:update']
  },
  delete: {
    show: true,
    api: financialGoodsPrice.deletes,
    auth: ['financial:goodsPrice:delete'],
    realApi: financialGoodsPrice.realDeletes,
    realAuth: ['financial:goodsPrice:realDeletes']
  },
  recovery: {
    show: true,
    api: financialGoodsPrice.recoverys,
    auth: ['financial:goodsPrice:recovery']
  },
  import: {
    show: true,
    url: 'financial/goodsPrice/import',
    templateUrl: 'financial/goodsPrice/downloadTemplate',
    auth: ['financial:goodsPrice:import']
  },
  export: {
    show: true,
    url: 'financial/goodsPrice/export',
    auth: ['financial:goodsPrice:export']
  },
  
})

const columns = reactive([
  {
    title: "",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入"
    }
  },
  {
    title: "名称",
    dataIndex: "name",
    formType: "input",
    search: true
  },
  {
    title: "年份",
    dataIndex: "year",
    formType: "input",
    search: true
  },
  {
    title: "状态",
    dataIndex: "status",
    formType: "select",
    search: true,
    dict: {
      data: [
        {
          label: "禁用",
          value: "0"
        },
        {
          label: "启用",
          value: "1"
        }
      ],
      translation: true
    }
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "修改时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "创建者",
    dataIndex: "created_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "修改者",
    dataIndex: "updated_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  }
])
</script>
<script> export default { name: 'financial:goodsPrice' } </script>